<template>
  <div class="app-container">
    <div style="display: flex;flex-flow: row nowrap;margin-left: 9%">
      <div style="border:1px;background-color: #4e8dff; width: 6px;height: 20px"></div>
      <span style="margin-left: 10px">任务信息</span>
    </div>
    <el-form ref="tempForm" :model="tempForm" label-width="140px"
             style="margin-left: 25%;">
      <el-row>
        <el-col :span="16">
          <el-form-item label="任务标题" prop="examineTitle">
            <el-input v-model="tempForm.examineTitle" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="16">
          <el-form-item label="任务内容" prop="examineContents">
            <editor v-model="tempForm.examineContents" :readOnly="true" :min-height="192"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="16">
          <el-form-item label="附件" prop="examineAttachFile">
            <file-upload v-model="tempForm.examineAttachFile" :isShowTip="false"/>
          </el-form-item>
        </el-col>
      </el-row>
      <!--      <el-row>-->
      <!--        <el-col :span="16">-->
      <!--          <el-form-item label="截止时间" prop="endTime">-->
      <!--            <el-date-picker-->
      <!--              v-model="baseForm.endTime"-->
      <!--              type="date"-->
      <!--              :picker-options="datePickerValid"-->
      <!--              style="width: 100%"-->
      <!--            >-->
      <!--            </el-date-picker>-->
      <!--          </el-form-item>-->
      <!--        </el-col>-->
      <!--      </el-row>-->
    </el-form>
    <div style="display: flex;flex-flow: row nowrap;margin-left: 80px">
      <div style="border:1px;background-color: #4e8dff; width: 6px;height: 20px"></div>
      <span style="margin-left: 10px">任务详情</span>
    </div>
    <el-form ref="tempForm" :model="baseForm"  label-width="140px"
             style="margin-left: 25%;">
      <el-row>
        <el-col :span="16">
          <el-form-item label="任务描述" prop="missionDescribe">
            <editor v-model="baseForm.missionDescribe" :readOnly="true" :min-height="192"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="16">
          <el-form-item label="上传附件" prop="attachFile">
            <file-upload v-model="baseForm.attachFile" :isShowTip="false"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div style="margin: 2% auto auto 40%;">
      <el-button class="form_button_item" @click="closeBtnHandler">返回</el-button>
    </div>
  </div>
</template>

<script>
import {addTask, getTask, updateTask} from "@/api/examine/task/api";
import {getExamineUserInfo, updateExamineUser} from "@/api/examine/user/api";

export default {
  name: "Add",
  components: {},
  data() {
    return {
      datePickerValid: {
        disabledDate(time) {
          return time.getTime() <= new Date().getTime() - 8.64e7;
        }
      },
      title: "",
      cycleVal: '',
      deptName: '',
      isUpdate: false,
      rulesData: {},
      receiveData: {},
      saveBtnLoading: false,
      // 表单参数
      tempForm: {},
      baseForm: {},
      isReceived: false,
      id: '',
      examineId: ''
    }
  },
  created() {
    this.initPage();
  },
  methods: {
    initPage() {
      this.reset()
      this.id = this.$route.query.id;
      if (this.id) {
        this.isUpdate = true;
        getExamineUserInfo(this.id).then(resp => {
          this.baseForm.id = this.id
          this.tempForm = resp.data
          this.baseForm = resp.data
          this.isReceived = resp.data.isReceived > 0
          this.examineId=resp.data.examineId
        })
      }
    },
    closeBtnHandler() {
      this.reset()
      // 关闭当前页面
      this.$tab.closeOpenPage();
      // 刷新列表页面
      this.$tab.refreshPage({path: "/training/submitTable",query:{examineId:this.examineId}});
    },
    // 表单重置
    reset() {
      this.baseForm = {
        missionDescribe: undefined,
        attachFile: undefined,
        isSubmitted: undefined,
        isReceived: undefined,
        status: undefined
      };
      this.resetForm("baseForm");
    }
  }
}
</script>

<style scoped>
::v-deep .el-input.is-disabled .el-input__inner {
  background-color: #fff;
  color: #606266;
}

::v-deep .el-textarea.is-disabled .el-textarea__inner {
  background-color: #fff;
  color: #606266;
}

::v-deep .el-radio__input.is-disabled + span.el-radio__label {
  background-color: #fff;
  color: #606266;
}
</style>
